################################################################################
##
##  Version 3.x, Copyright (C) 2004-2013, Marcus Holland-Moritz.
##  Version 2.x, Copyright (C) 2001, Paul Marquess.
##  Version 1.x, Copyright (C) 1999, Kenneth Albanowski.
##
##  This program is free software; you can redistribute it and/or
##  modify it under the same terms as Perl itself.
##
################################################################################

=provides

__UNDEFINED__

=implementation

__UNDEFINED__  mPUSHs(s)        PUSHs(sv_2mortal(s))
__UNDEFINED__  PUSHmortal       PUSHs(sv_newmortal())
__UNDEFINED__  mPUSHp(p,l)      sv_setpvn(PUSHmortal, (p), (l))
__UNDEFINED__  mPUSHn(n)        sv_setnv(PUSHmortal, (NV)(n))
__UNDEFINED__  mPUSHi(i)        sv_setiv(PUSHmortal, (IV)(i))
__UNDEFINED__  mPUSHu(u)        sv_setuv(PUSHmortal, (UV)(u))

__UNDEFINED__  mXPUSHs(s)       XPUSHs(sv_2mortal(s))
__UNDEFINED__  XPUSHmortal      XPUSHs(sv_newmortal())
__UNDEFINED__  mXPUSHp(p,l)     STMT_START { EXTEND(sp,1); sv_setpvn(PUSHmortal, (p), (l)); } STMT_END
__UNDEFINED__  mXPUSHn(n)       STMT_START { EXTEND(sp,1); sv_setnv(PUSHmortal, (NV)(n)); } STMT_END
__UNDEFINED__  mXPUSHi(i)       STMT_START { EXTEND(sp,1); sv_setiv(PUSHmortal, (IV)(i)); } STMT_END
__UNDEFINED__  mXPUSHu(u)       STMT_START { EXTEND(sp,1); sv_setuv(PUSHmortal, (UV)(u)); } STMT_END

=xsubs

void
mPUSHs()
        PPCODE:
        EXTEND(SP, 3);
        mPUSHs(newSVpv("foo", 0));
        mPUSHs(newSVpv("bar13", 3));
        mPUSHs(newSViv(42));
        XSRETURN(3);

void
mPUSHp()
        PPCODE:
        EXTEND(SP, 3);
        mPUSHp("one", 3);
        mPUSHp("two", 3);
        mPUSHp("three", 5);
        XSRETURN(3);

void
mPUSHn()
        PPCODE:
        EXTEND(SP, 3);
        mPUSHn(0.5);
        mPUSHn(-0.25);
        mPUSHn(0.125);
        XSRETURN(3);

void
mPUSHi()
        PPCODE:
        EXTEND(SP, 3);
        mPUSHi(-1);
        mPUSHi(2);
        mPUSHi(-3);
        XSRETURN(3);

void
mPUSHu()
        PPCODE:
        EXTEND(SP, 3);
        mPUSHu(1);
        mPUSHu(2);
        mPUSHu(3);
        XSRETURN(3);

void
mXPUSHs()
        PPCODE:
        mXPUSHs(newSVpv("foo", 0));
        mXPUSHs(newSVpv("bar13", 3));
        mXPUSHs(newSViv(42));
        XSRETURN(3);

void
mXPUSHp()
        PPCODE:
        mXPUSHp("one", 3);
        mXPUSHp("two", 3);
        mXPUSHp("three", 5);
        XSRETURN(3);

void
mXPUSHn()
        PPCODE:
        mXPUSHn(0.5);
        mXPUSHn(-0.25);
        mXPUSHn(0.125);
        XSRETURN(3);

void
mXPUSHi()
        PPCODE:
        mXPUSHi(-1);
        mXPUSHi(2);
        mXPUSHi(-3);
        XSRETURN(3);

void
mXPUSHu()
        PPCODE:
        mXPUSHu(1);
        mXPUSHu(2);
        mXPUSHu(3);
        XSRETURN(3);

=tests plan => 10

ok(join(':', &Devel::PPPort::mPUSHs()), "foo:bar:42");
ok(join(':', &Devel::PPPort::mPUSHp()), "one:two:three");
ok(join(':', &Devel::PPPort::mPUSHn()), "0.5:-0.25:0.125");
ok(join(':', &Devel::PPPort::mPUSHi()), "-1:2:-3");
ok(join(':', &Devel::PPPort::mPUSHu()), "1:2:3");

ok(join(':', &Devel::PPPort::mXPUSHs()), "foo:bar:42");
ok(join(':', &Devel::PPPort::mXPUSHp()), "one:two:three");
ok(join(':', &Devel::PPPort::mXPUSHn()), "0.5:-0.25:0.125");
ok(join(':', &Devel::PPPort::mXPUSHi()), "-1:2:-3");
ok(join(':', &Devel::PPPort::mXPUSHu()), "1:2:3");
